package com.zhijiaoyun.service.impl;

import com.zhijiaoyun.dao.IItemDao;
import com.zhijiaoyun.model.Item;
import com.zhijiaoyun.model.dto.PageList;
import com.zhijiaoyun.service.IItemService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author shisfish
 * @date 2018/1/18
 */
@Service(value = "itemService")
public class ItemServiceImpl implements IItemService {

    @Resource
    IItemDao itemDao;

    @Override
    public void insert(Item item) {
        itemDao.insert(item);
    }

    @Override
    public void update(Item item) {
        itemDao.updateByPrimaryKey(item);
    }

    @Override
    public void delete(Item item) {

    }

    @Override
    public void deleteById(Long id) {

    }

    @Override
    public Item selectByPrimaryKey(Long id) {
        return null;
    }

    @Override
    public PageList<Item> page(int pageIndex, int pageSize, Object... args) {
        return null;
    }

    @Override
    public Item getByKeyType(String key, String type) {
        return itemDao.selectByKeyType(key, type);
    }

    @Override
    public List<Item> getByType(String type) {
        return itemDao.selectByType(type);
    }

    @Override
    public List<Item> getByKeysType(String type, List<String> keys) {
        return itemDao.getByKeysType(type, keys);
    }

    @Override
    public String getValueByKeyType(String key, String type) {
        Item item = getByKeyType(key, type);
        if (item != null) {
            return item.getValue();
        }
        return null;
    }
}

